<template>
	<view>
		<view class="goods_cate">
			<!-- <view class="tabSearch">
				<view class="pr">
					<view class="Search">
						<view class="margin-horizontal-main padding-horizontal-main bg-white">
							<u--input placeholder="请输入内容" shape="circle" clearable v-model="memberId"
								@input="handleInput"></u--input>
						</view>
					</view>
				</view>
			</view> -->
			<view class="content">
				<view class="">
					<label>实时总业绩：</label>
					<span>{{detailed.groupBuy?detailed.groupBuy:0}}</span>
				</view>
				<view class="">
					<label>今日新增业绩：</label>
					<span>{{yyyyy?yyyyy:0}}</span>
				</view>
				<view class="">
					<label>昨日新增业绩：</label>
					<span>{{detailed.lastdayGroupBuy?detailed.lastdayGroupBuy:0}}</span>
				</view>
			</view>
			<view class="Cate">
				<scroll-view class="left_scroll" scroll-y="true">
					<view v-for="(item,index) in left_scoll" :key="index" class="left_title"
						:class="index == indexValue ? 'left_color': ''" @click="ClickIndex(index,item.id)">
						{{item.cateName}}
					</view>
				</scroll-view>
				<scroll-view class="right_scroll" scroll-y="true" v-if="fuuuuuuck">
					<view class="right_goods_info" v-for="(item,index) in rightList" :key="index"
						@click="Navgetto(item)">
						<view class="right_goods_image">
							<image v-if="item.avatar" :src="util.imageApi+item.avatar"></image>
							<image v-else src="../../static/3x/tjxhT.png"></image>
						</view>
						<view class="right_goods_info_title" v-if="fuck">
							<view class="storeName">
								{{item.nickName}}
							</view>
							<view class="storeName">
								id：{{item.memberId}}
							</view>
							<view class="storeName" v-if="item.memberId==MemberId">
								自购：{{item.selfBuying}}
							</view>
							<view class="storeName" v-else>
								总业绩：{{item.groupPerformanceSum?item.groupPerformanceSum:0}}
							</view>
						</view>
						<view class="right_goods_info_title" v-else>
							<view class="storeName">
								{{item.nickName}}
							</view>
							<view class="storeName">
								id：{{item.memberId}}
							</view>
							<view class="storeName">
								<view v-if="item.groupLevel==1">初级农场主</view>
								<view v-if="item.groupLevel==2">中级农场主</view>
								<view v-if="item.groupLevel==3">高级农场主</view>
								<view v-if="item.groupLevel==4">超级农场主</view>
								<view v-if="item.groupLevel==5">特级农场主</view>
								<view v-if="item.groupLevel==6">V6</view>
							</view>

						</view>
					</view>
				</scroll-view>

				<scroll-view class="right_scroll" scroll-y="true" v-else>
					<view class="right_goods_info" v-for="(item,index) in groupBuylist" :key="index"
						@click="Navgetto(item)">
						<view class="right_goods_image">
							<image v-if="item.avatar" :src="util.imageApi+item.avatar"></image>
							<image v-else src="../../static/3x/tjxhT.png" mode=""></image>
						</view>
						<view class="right_goods_info_title">
							<view class="storeName">
								{{item.nickName}}
							</view>
							<view class="storeName">
								id：{{item.memberId}}
							</view>
							<view class="storeName" v-if="ppppppp">
								总业绩：{{item.groupBuy}}
							</view>
						</view>
					</view>
				</scroll-view>
			</view>
		</view>
	</view>
</template>

<script>
	import util from "@/util/index.js"
	export default {
		data() {
			return {
				MemberId: '',
				detailed: {},
				memberId: "",
				util: util,
				left_scoll: [{
						cateName: "一级客户",
						id: "1"
					},
					{
						cateName: "二级客户",
						id: "2"
					},
					{
						cateName: "一般客户",
						id: "3"
					},
					{
						cateName: "昨日新增客户",
						id: "4"
					},
					{
						cateName: "农场主",
						id: "5"
					},
				],
				indexValue: 0,
				rightList: [],
				fuck: true,
				groupBuylist: [],
				fuuuuuuck: true,
				yyyyy: '',
				ppppppp: true,
			}
		},
		methods: {
			SearchUser() {
				this.$http({
					url: "/member/getMyPage"
				}).then(res => {
					this.MemberId = res.data.data.memberId
				})
			},
			Navgetto(item) {
				uni.navigateTo({
					url: '/pages/salesDetailed/salesDetailed?id=' + item.memberId
				})
			},
			// handleInput() {
			// 	this.ClickIndex(this.indexValue, this.indexValue + 1)
			// },
			ClickIndex(index, id) {
				this.indexValue = index
				this.rightList = []
				this.groupBuylist = []
				this.fuck = true
				this.ppppppp = true
				if (id == 3) {
					this.fuuuuuuck = false
					this.ppppppp = false
					this.$http({
						url: '/member/getMyTeam',
						method: 'GET',
						data: {
							level: 3,
							memberId: this.memberId,
						},
					}).then(res => {
						this.groupBuylist = res.data.data
					})
				} else if (id == 5) {
					this.fuuuuuuck = true
					this.fuck = false
					this.ppppppp = true
					this.$http({
						url: '/member/nong',
						method: 'GET',
						data: {
							memberId: this.MemberId
						}
					}).then(res => {
						this.rightList = JSON.parse(res.data.data)
					})
				} else {
					this.fuuuuuuck = false
					// this.rightList = []
					this.$http({
						url: '/member/getMyTeam',
						method: 'GET',
						data: {
							level: id,
							memberId: this.memberId
						}
					}).then(res => {
						this.rightList = res.data.data
						this.rightList.forEach((item, index) => {
							this.$http({
								url: '/member/getPerformanceInfo',
								method: 'GET',
								data: {
									memberIdParem: item.memberId,
									token: uni.getStorageSync('secretKey')
								}
							}).then(res => {
								this.groupBuylist.push(res.data.data)
							})
						})
					})
				}
			},
		},
		onLoad() {
			this.SearchUser()
			this.ClickIndex(0, 1)
			this.$http({
				url: '/member/getPerformanceInfo',
				method: 'GET',
				data: {
					token: uni.getStorageSync('secretKey')
				}
			}).then(res => {
				if (res.data.data.memberId == 25447448) {
					this.seflBuya = 0
				} else {
					this.seflBuya = res.data.data.seflBuy
				}
				this.detailed = res.data.data
			})
			setTimeout(() => {
				this.$http({
					url: "/member/newResultsToday",
					data: {
						id: this.MemberId
					}
				}).then(res => {
					this.yyyyy = res.data.data
				})
			}, 3000)
		},
	}
</script>

<style lang="scss" scoped>
	@import './sales.css';
</style>
